import requests
import os

TEMP_PATH = os.path.join(os.path.abspath(os.path.join(os.getcwd(),"..")), 'temp')
def download(url):
    print("开始下载,",url)
    rs = requests.get(url)
    if rs.status_code == 200:
        filename =os.path.join(TEMP_PATH,url.split('/')[-1])
        with open(filename,'wb') as f:
            f.write(rs.content)
        print("下载结束,", url)
    else:
        print("下载失败")

def main():
    urls = [
        'https://17dz.com/home/images/auto-1.png',
        'https://17dz.com/home/images/auto-2.png',
        'https://17dz.com/home/images/auto-3.png'
    ]
    for url in urls:
        download(url)


if __name__ == "__main__":
    main()
    # print(os.path.abspath(__file__))
    # print(os.path.basename(__file__))
    # print(os.path.dirname(__file__))
    # print(os.path.abspath(os.path.dirname(__file__)))
    # print(os.path.abspath(os.path.join(os.getcwd(),".."))) #获取上级目录
